/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package suministros.ejb30.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Diana
 */
@Entity
@Table(name = "StockAlmacen")
@NamedQueries({
    @NamedQuery(name = "StockAlmacen.findAll", query = "SELECT s FROM StockAlmacen s"),
    @NamedQuery(name = "StockAlmacen.findByIDSuministro", query = "SELECT s FROM StockAlmacen s WHERE s.stockAlmacenPK.iDSuministro = :iDSuministro"),
    @NamedQuery(name = "StockAlmacen.findByIdSubalmacen", query = "SELECT s FROM StockAlmacen s WHERE s.stockAlmacenPK.idSubalmacen = :idSubalmacen"),
    @NamedQuery(name = "StockAlmacen.findByStockMinimo", query = "SELECT s FROM StockAlmacen s WHERE s.stockMinimo = :stockMinimo"),
    @NamedQuery(name = "StockAlmacen.findByStock", query = "SELECT s FROM StockAlmacen s WHERE s.stock = :stock"),
    @NamedQuery(name = "StockAlmacen.findByUsuario", query = "SELECT s FROM StockAlmacen s WHERE s.usuario = :usuario"),
    @NamedQuery(name = "StockAlmacen.findByMac", query = "SELECT s FROM StockAlmacen s WHERE s.mac = :mac")})
public class StockAlmacen implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected StockAlmacenPK stockAlmacenPK;
    @Column(name = "stock_minimo")
    private BigDecimal stockMinimo;
    @Column(name = "stock")
    private BigDecimal stock;
    @Column(name = "usuario")
    private String usuario;
    @Column(name = "mac")
    private String mac;
    @JoinColumn(name = "id_empresa", referencedColumnName = "id_empresa")
    @ManyToOne
    private Empresa idEmpresa;
    @JoinColumn(name = "id_subalmacen", referencedColumnName = "id_SubAlmacen", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private SubAlmacen subAlmacen;
    @JoinColumn(name = "ID_Suministro", referencedColumnName = "ID_Suministro", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Suministros suministros;
    @Column(name = "fecha_operacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaOperacion;

    public StockAlmacen() {
    }

    public StockAlmacen(StockAlmacenPK stockAlmacenPK) {
        this.stockAlmacenPK = stockAlmacenPK;
    }

    public StockAlmacen(String iDSuministro, String idSubalmacen) {
        this.stockAlmacenPK = new StockAlmacenPK(iDSuministro, idSubalmacen);
    }

    public StockAlmacenPK getStockAlmacenPK() {
        return stockAlmacenPK;
    }

    public void setStockAlmacenPK(StockAlmacenPK stockAlmacenPK) {
        this.stockAlmacenPK = stockAlmacenPK;
    }

    public BigDecimal getStockMinimo() {
        return stockMinimo;
    }

    public void setStockMinimo(BigDecimal stockMinimo) {
        this.stockMinimo = stockMinimo;
    }

    public BigDecimal getStock() {
        return stock;
    }

    public void setStock(BigDecimal stock) {
        this.stock = stock;
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public Empresa getIdEmpresa() {
        return idEmpresa;
    }

    public void setIdEmpresa(Empresa idEmpresa) {
        this.idEmpresa = idEmpresa;
    }

    public SubAlmacen getSubAlmacen() {
        return subAlmacen;
    }

    public void setSubAlmacen(SubAlmacen subAlmacen) {
        this.subAlmacen = subAlmacen;
    }

    public Suministros getSuministros() {
        return suministros;
    }

    public void setSuministros(Suministros suministros) {
        this.suministros = suministros;
    }

    public Date getFechaOperacion() {
        return fechaOperacion;
    }

    public void setFechaOperacion(Date fechaOperacion) {
        this.fechaOperacion = fechaOperacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (stockAlmacenPK != null ? stockAlmacenPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {

        if (!(object instanceof StockAlmacen)) {
            return false;
        }
        StockAlmacen other = (StockAlmacen) object;
        if ((this.stockAlmacenPK == null && other.stockAlmacenPK != null) || (this.stockAlmacenPK != null && !this.stockAlmacenPK.equals(other.stockAlmacenPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "suministros.ejb30.entity.StockAlmacen[stockAlmacenPK=" + stockAlmacenPK + "]";
    }

}
